﻿@using NTQOnlineExam.Services.Infrastructure.MVC
@model NTQOnlineExamFrontend.Models.TermDetailViewModel

@{
    ViewBag.Title = this.LocalResources("PageTitle");
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="pricing-inner">
    <div class="pricing-header">
         @if (@Model.Term.ExpiryDays.HasValue)
        {
            <div class="text-muted">Expires after<strong> @Model.Term.ExpiryDays</strong> days</div>
        }
        else
        {
            <div class="text-muted">&nbsp;</div>
        }
        <a class="no-hover">
            <h5>@Model.Term.TermName</h5>
            <span>(@Model.Sections.Sum(x => x.TotalQuestion) @this.LocalResources("Questions"))</span>
        </a>
    </div>
    <div class="pricing-number">
        @if (Model.Term.Price.HasValue)
        {
            @Model.Term.Price.Value.ToString("#.## AUD");
        }
    </div>
    <div class="pricing-body">
        <strong class="margin-top-5">List of sections</strong>
        <ul class="list-style-none">
            @foreach (var sectionTerm in Model.Sections)
            {
                if (@sectionTerm.TotalQuestion > 0)
                {
                    <li>@sectionTerm.SectionName (@sectionTerm.TotalQuestion @this.LocalResources("Questions"))</li>
                }
            }
        </ul>
    </div>
</div>

<div class="controls margin-top-10">
     @if (Model.Term.IsPaid)
    {
        <a class="btn btn-sm btn-blue" style="cursor: not-allowed" href="#" onclick="return false;">Purchased</a>
    }
    else
    {
            <button class="btn btn-sm btn-red" onclick="BasketClient.AddToBasket(@Model.Term.TermId);"><i class="fa fa-shopping-cart"></i>&nbsp;Add to cart</button>
    }
    <button class="btn btn-sm" onclick="baskToTerm();" type="button">Back</button>
</div>


<script type="text/javascript">
    function baskToTerm() {
        window.location.href = '@Url.RouteUrl(new { Controller = "Term", Action = "GetTerms", year = Model.ClassYear })';
    };

    $(document).ready(function () {
        BasketClient.SetAddToBasketUrl('@Url.RouteUrl(new { Controller = "Basket", Action = "AddToBasket" })');
    });
</script>
